<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld" %>
<%@ taglib prefix="fmt" uri="/WEB-INF/tld/fmt.tld" %>
<%@ taglib prefix="fn" uri="/WEB-INF/tld/fn.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>  
<head>  
	<!-- IE 浏览作用 兼容模式打开页面。 chrome=1 开启 chrome 支持，适用多个核的浏览器。 -->
	<meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />
	<meta charset="UTF-8">  
	<title>${sys_pt_login }</title>  
	<link rel="icon" type="image/ico" href="${syspath}/deng/images/icons/system.png" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="format-detection" content="telephone=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link href="${syspath }/deng/source/plugins/newAdmin/vendors/base/flaticon.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/icons.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/style.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/using/base/theme/default/style.bundle.css" rel="stylesheet" type="text/css" />
	<!-- 基础插件样式开始 -->
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/style.css" rel="stylesheet" type="text/css" />
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- 基础插件样式结束 -->
    <link rel="stylesheet" type="text/css" href="${syspath }/view/pc/xt-view/xt-login/icon/iconfont.css" />
	<script src="${syspath }/view/pc/xt-view/xt-login/icon/iconfont.js" type="text/javascript" charset="utf-8"></script>
    <!-- 基础插件开始 -->
    <script src="${syspath}/deng/source/plugins/newAdmin/vendors/base/jquery.min.js" type="text/javascript"></script>
    <script src="${syspath }/deng/source/plugins/newAdmin/bootstrap/4.0.0/js/bootstrap.min.js" type="text/javascript"></script>
    <!-- 基础插件结束 -->
    <!-- 自定义主题样式开始 -->
	<link href="${syspath }/deng/source/css/login.css" rel="stylesheet" type="text/css" />
	<!-- 自定义主题样式结束 -->
    <!-- 提示插件开始 -->
    <link href="${syspath }/deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.css" rel="stylesheet" type="text/css" />
    <script src="${syspath }/deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.js" type="text/javascript"></script>
    <script src="${syspath }/deng/source/plugins/newAdmin/bootstrap/bootbox.js" type="text/javascript"></script>
    <!-- 提示插件结束 -->
	<!-- bootstrap验证框架开始 -->
	<link rel="stylesheet" type="text/css" href="${syspath }/deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.css" />
	<script src="${syspath }/deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.js" type="text/javascript"></script>
	<!-- bootstrap验证框架结束 -->
	<!-- 公共模块包含上传控件，共同JS封装 -->
	<script type="text/javascript" src="${syspath}/deng/source/js/boot.min.js"></script>
	<style>
	.titlee {
		width: 100%;
		margin: auto;
		padding-top: 18%;
		padding-left: 4%;
	}
	.input-icon>i {
	    position: absolute;
	    margin-top: 12px;
	}
	.bv-form .help-block {
	    color: red;
	}     
	</style>
	<script type="text/javascript">
    	var basePath = "${syspath}";
    	var sys_pt_login = "${sys_pt_login}";
	</script>
</head>
<body>
	<div class="big-bg">
		<div class="bg">
			<div class="describtion">
	            <h2>${sys_pt_login_title1}</h2>
	            <p>${sys_pt_login_title2}</p>
	            <p>${sys_pt_login_title3}</p>
	            <p>${sys_pt_login_title4}</p>
	        </div>
	        <!--<div class="titlee">
	            <img src="images/login-new/title.png" style="width: 50%;" alt="" />
	        </div>-->
			<div class="contain">
				<div class="login"></div>
				<p class="title">${sys_pt_login }</p>
				<div class="line"></div>
				<form id="loginForm" method="post">
					<!-- 
					<div class="form-group common">
						<div class="input-icon">
							<i class="iconfont icon-bianhao"></i>
							<input class="form-control" type="text" placeholder="请输入编码" name="customerNo" id="customerNo" autocomplete="off" />
						</div>
					</div>
					<div class="form-group common">
						<div class="input-icon">
							<i class="iconfont icon-gongsimingcheng"></i>
							<input class="form-control" type="text" placeholder="自动生成企业名称" id="msg" style="background: transparent;" readonly="readonly" />
						</div>
					</div> 
					-->
					<div class="form-group common">
						<div class="input-icon">
							<i class="flaticon-user-ok"></i>
							<input class="form-control" type="text" placeholder="请输入用户名" name="userName" id="userName" autocomplete="off" />
						</div>
					</div>
					<div class="form-group common">
						<div class="input-icon">
							<i class="flaticon-lock"></i>
							<input class="form-control" type="password" placeholder="请输入密码" name="password" id="password" autocomplete="off" />
						</div>
					</div>
					<div class="row" style="padding:0 50px!important">
						<div class="col-sm-6" style="padding-right: 0;">
							<div class="form-group common-li">
								<div class="input-icon">
									<i class="flaticon-logout" style="font-size: 28px;"></i>
									<input class="form-control" type="text" placeholder="请输入验证码" name="validateCode" id="validateCode" />
								</div>
							</div>
						</div>
						<div class="col-sm-3">
							<img src="${syspath}/VerifyCodeServlet" id="safecode" width="180" onclick="this.src=${syspath}/VerifyCodeServlet"/>
							<br>
							<a href="javascript:clickYZM()">换一张</a><br><br>
						</div>
					</div>
					<div class="form-group form-login">
						<input type="button" id="loginBtn" class="btn" onclick="login()" value="登录">
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	clickYZM();
	function callFocus() {
		var userName = $('#userName').val();
		var password = $('#password').val();
		var validateCode = $('#validateCode').val();
		if(userName == null || userName == '') {
			return $('#userName')[0].focus();
		}
		if(password == null || password == '') {
			return $('#password')[0].focus();
		}
		if(validateCode == null || validateCode == '') {
			return $('#validateCode')[0].focus();
		}
	}
	$(document).ready(function() {
		if(getnavigator() == 7 || getnavigator() == 8 || getnavigator() == 9 || getnavigator() == 6 || getnavigator() == 0) {
			document.write("平台支持IE10及以上浏览器或谷歌，火狐，360等浏览器");
			return;
		}
		$('#myModal').modal({
			backdrop: 'static',
			keyboard: false
		});
		if(getCookie('readme') == 'readme') {
			$("[name='readme']").attr("checked", 'true');
			$('#userName').val(getCookie('XTUSERNAMECOOKIE'));
			$('#password').val(getCookie('XTUSERPASSWORDCOOKIE'));
		}
	});

	//刷新验证码
	function clickYZM() {
		document.getElementById('safecode').src = basePath+"/VerifyCodeServlet?"+new Date();
	}

	$('#loginForm').bootstrapValidator({
		message: '此值不是有效的',
		feedbackIcons: {},
		fields: {
			userName: {
				validators: {
					notEmpty: {
						message: '用户账号不能为空'
					},
					stringLength: {
						min: 1,
						max: 30,
						message: '用户账号字符长度不能超过30个'
					}
				}
			},
			password: {
				validators: {
					notEmpty: {
						message: '密码不能为空'
					},
					stringLength: {
						min: 1,
						max: 20,
						message: '密码字符长度不能超过20个'
					}
				}
			},
			validateCode: {
				validators: {
					notEmpty: {
						message: '验证码不能为空'
					},
					stringLength: {
						min: 6,
						max: 6,
						message: '验证码只能为6个字符'
					}
				}
			}
		}
	});

	$(function() {
		document.onkeydown = function(e) {
			var ev = document.all ? window.event : e;
			if(ev.keyCode == 13) {
				login();
			}
		}
	});
	//提交登录form
	function login() {
		callFocus();
		var bootform = $('#loginForm');
		if(typeof(bootform) == "undefined" || null == bootform || '' == bootform) {
			window.parent.toastrBoot(4, "未能获取到form对象!");
			return;
		}
		//验证
		var boostrapValidator = bootform.data('bootstrapValidator');
		boostrapValidator.validate();
		//验证有效开启发送异步请求
		if(boostrapValidator.isValid()) {
			$("#loginBtn").attr("disabled", true);
			$("#loginBtn").val("正在登录中......")
			$.ajax({
				url: basePath + '/login/login',
				type: 'POST', //PUT DELETE POST
				data: bootform.serialize(),
				success: function(result) {
					call(result)
				},
				error: function() {
					$("#loginBtn").val("登录");
					$("#loginBtn").attr("disabled", false);
				}
			})
		} else {
			//window.parent.toastrBoot(4,"存在不合法的字段!");
		}
	}

	function call(result) {
		try {
			var obj = eval("(" + result + ")");
			if(obj.success == false) {
				clickYZM();
				window.parent.toastrBoot(4, obj.msg);
				$("#loginBtn").val("登录");
				$("#loginBtn").attr("disabled", false);
			} else {
				clearCookie('readme');
				clearCookie('XTUSERNAMECOOKIE');
				clearCookie('XTUSERPASSWORDCOOKIE');
				if($('#readme').is(':checked')) {
					if(null == getCookie('readme') || '' == getCookie('readme')) {
						setCookie('readme', 'readme', 240);
						setCookie('XTUSERNAMECOOKIE', $('#userName').val(), 240);
						setCookie('XTUSERPASSWORDCOOKIE', $('#password').val(), 240);
					}
				}
				$("#loginBtn").val("身份认证成功，开始进入平台......");
				window.parent.toastrBoot(3, "身份认证成功，开始进入平台......");
				window.location.href = basePath + "/index/index.html";
			}
		} catch(e) {
			$("#loginBtn").val("登录");
			$("#loginBtn").attr("disabled", false);
		}
	}

	document.onreadystatechange = pagecomplete;
	function pagecomplete() {
		if(document.readyState == "complete") {
			setTimeout(function() {
				callFocus();
			}, 500);
		}
	}
</script>
</html> 